//
//  ColorTableViewCell.m
//  BuffetNews
//
//  Created by 李荃荃 on 14-11-9.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "ColorTableViewCell.h"

@implementation ColorTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:self.title];
        [_title release];
        self.button1 = [UIButton buttonWithType:UIButtonTypeSystem];
        
        [self.button1 setBackgroundImage:[UIImage imageNamed:@"moren0.png"] forState:UIControlStateNormal];
        
        [self.button1 addTarget:self action:@selector(buttonAction1:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.button1];
        
        self.button2 = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.button2 setBackgroundImage:[UIImage imageNamed:@"moren1.png"] forState:UIControlStateNormal];
        [self.button2 addTarget:self action:@selector(buttonAction2:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.button2];
        
        self.button3 = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.button3 setBackgroundImage:[UIImage imageNamed:@"moren2.png"] forState:UIControlStateNormal];
        [self.button3 addTarget:self action:@selector(buttonAction3:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.button3];
        
        self.button4 = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.button4 setBackgroundImage:[UIImage imageNamed:@"moren3.png"] forState:UIControlStateNormal];
        [self.button4 addTarget:self action:@selector(buttonAction4:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.button4];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.title.frame = CGRectMake(10, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 2);
    
    self.button1.frame = CGRectMake(10, self.contentView.frame.size.height / 2, self.contentView.frame.size.width / 4 - 10, self.contentView.frame.size.height / 2);
    
    self.button2.frame = CGRectMake(self.contentView.frame.size.width / 4 + 10, self.contentView.frame.size.height / 2, self.contentView.frame.size.width / 4 - 10, self.contentView.frame.size.height / 2);
    
    self.button3.frame = CGRectMake(self.contentView.frame.size.width / 2 + 10, self.contentView.frame.size.height / 2, self.contentView.frame.size.width / 4 - 10, self.contentView.frame.size.height / 2);
    
    self.button4.frame = CGRectMake(self.contentView.frame.size.width / 4 * 3 + 10, self.contentView.frame.size.height / 2, self.contentView.frame.size.width / 4 - 10, self.contentView.frame.size.height / 2);
    
}

- (void)buttonAction1:(UIButton *)button
{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    NSString *string = @"moren0.png";
   
    [center postNotificationName:@"topicColor" object:string];
}

- (void)buttonAction2:(UIButton *)button
{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    NSString *string = @"moren1.png";
    [center postNotificationName:@"topicColor" object:string];
}

- (void)buttonAction3:(UIButton *)button
{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    NSString *string = @"moren2.png";
    [center postNotificationName:@"topicColor" object:string];
}
- (void)buttonAction4:(UIButton *)button
{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    NSString *string = @"moren3.png";
    [center postNotificationName:@"topicColor" object:string];
}

- (void)awakeFromNib
{
    // Initialization code
}
- (void)dealloc
{
    [_title release];
    [_button1 release];
    [_button2 release];
    [_button3 release];
    [_button4 release];
    [super dealloc];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
